/*------------------------------------------------------------------------------
 * Copyright 2012 NCR Corporation
 *------------------------------------------------------------------------------
 * All revision information is updated automatically from source code control
 * change records - please do not manually edit.
 *------------------------------------------------------------------------------
 *
 * $LastChangedRevision:: 2031                                     $
 * $LastChangedBy:: rb250096                                       $
 * $LastChangedDate:: 2012-04-08 18:21:06 -0400 (Sun, 08 Apr 2012) $
 */

package com.ncr.nep.dashboardcore.ui.client;

import com.google.gwt.event.shared.GwtEvent;

/**
 * Event dispatched by a {@link PopupMenu} when a menu item is clicked/selected.
 *
 * @author rb250096
 * @version $Revision: 2031 $
 */
public class PopupMenuEvent extends GwtEvent<PopupMenuHandler> {

    //--------------------------------------------------------------------------
    //
    //  Fields
    //
    //--------------------------------------------------------------------------

    /**
     * The event type.
     */
    public static final Type<PopupMenuHandler> TYPE =
            new Type<PopupMenuHandler>();

    /**
     * The ID of the menu item that was clicked.
     */
    protected String selectedMenuItemId;

    /**
     * The displayed label in the HTML for the selected menu item.
     */
    protected String selectedMenuItemLabel;

    //--------------------------------------------------------------------------
    //
    //  Constructors
    //
    //--------------------------------------------------------------------------

    /**
     * Constructor
     *
     * @param selectedMenuItemId The ID of the menu item that was selected.
     * @param selectedMenuItemLabel The displayed label for the menu item that
     *                              was selected.
     */
    public PopupMenuEvent(String selectedMenuItemId,
                          String selectedMenuItemLabel) {
        super();
        this.selectedMenuItemId = selectedMenuItemId;
        this.selectedMenuItemLabel = selectedMenuItemLabel;
    }

    @Override
    public Type<PopupMenuHandler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(PopupMenuHandler handler) {
        handler.onMenuItemSelected(this);
    }

    /**
     * Gets the ID of the menu item that was selected.
     *
     * @return The ID of the selected menu item.
     */
    public String getSelectedMenuItemId() {
        return selectedMenuItemId;
    }

    /**
     * Gets the displayed label for the menu item that was selected.
     *
     * @return The label of the selected menu item.
     */
    public String getSelectedMenuItemLabel() {
        return selectedMenuItemLabel;
    }
}
